const path = require('path');
const fpath = '/a/d/d/index.html';
// path.basename()接收两个参数：1.文件路径；2.后缀名
const fullName = path.basename(fpath);
const nameWithoutExt = path.basename(fpath,'.html');
console.log(fullName); // index.html
console.log(nameWithoutExt);// index

// 获取文件的扩展名:只接收文件路径
const fext = path.extname(fpath);
console.log(fext);//.html